using System;
using UnityEngine;
using UnityEngine.InputSystem;
using Utility.Attributes;
using Utility.GameEvents.Scriptable.Integrated;
using Random = UnityEngine.Random;

namespace Utility.GameEvents.Examples {
    public class Example : MonoBehaviour {
        [SerializeField, NotNull] private VoidGameEvent m_voidGameEvent;
        [SerializeField, NotNull] private IntGameEvent m_intGameEvent;
        [SerializeField, NotNull] private FloatGameEvent m_floatGameEvent;
        [SerializeField, NotNull] private StringGameEvent m_stringGameEvent;
        
        public void VoidExample() {
            Debug.Log("VoidExample");
        }

        public void IntExample(int value) {
            Debug.Log($"IntExample: {value}");
        }

        public void FloatExample(float value) {
            Debug.Log($"FloatExample: {value}");
        }

        public void StringExample(string value) {
            Debug.Log($"StringExample: {value}");
        }

        private void Update() {
            if (Keyboard.current.qKey.wasPressedThisFrame) {
                m_voidGameEvent.Raise();
            }else if (Keyboard.current.wKey.wasPressedThisFrame) {
                m_intGameEvent.Raise(Random.Range(0, 100));
            }else if (Keyboard.current.eKey.wasPressedThisFrame) {
                m_floatGameEvent.Raise(Random.Range(101f, 201f));
            }else if (Keyboard.current.rKey.wasPressedThisFrame) {
                var ran = ((char)UnityEngine.Random.Range('A', 'Z' + 1)).ToString();
                m_stringGameEvent.Raise(ran);
            }
        }
    }
}
